< previous page page_24 next page >

Page 24
Puzzle 6
Icon Fix This One
Most programmers are familiar with iconsthose cute little rectangular symbols that are used throughout Windows.1 Icons can be stored in individual icon files (typically with the extension .ico) or as resources within Windows executables and dynamic link libraries.
The Windows system provides a number of built-in icons that can be loaded using the LoadIcon function. This function is defined as follows under the Win32 documentation:
HICON LoadIcon(
    HINSTANCE hInstance, // handle of application instance
    LPCTSTR lpIconName   // icon-name string or icon resource identifier
   );
This looks quite simple. The hInstance parameter, like all handles, will be a Long and passed by value. The lpIconName parameter is a string. The type breaks down as follows:
LPLong (far) Pointer
CConstant, meaning that the API function does not change the contents of the string
TVaries depending on entry point. The string will be ANSI for the ANSI entry point, Unicode for the Unicode entry point.
STRNULL-terminated C string

The declaration is therefore
Private Declare Function LoadIcon Lib "user32.dll" Alias "LoadIconA" _
   ( ByVal hInstance As Long, _
   ByVal lpIconName As String) As Long
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
1 Rectangular, you ask? Icons are always rectangularbut portions of an icon can be made transparent, so they may seem to have many different shapes.

 
< previous page page_24 next page >